
<!--
 Thanks to http://www.guineacode.com/2011/facebook-app-authorization/
 for the FB.getLoginStatus example that allows all the Facebook
 authorization to be done client-side.
-->

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>Sapporo</title>
    <link type="text/css" rel="stylesheet" href="<?=base_url()?>css/styles.css"/>

    <!--[if IE]><![endif]-->
    <!--    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>-->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

</head>
<body>
<div id="fb-root"></div>
<div class="Container">
    <div id="Wrapper">
        <div class="Content" style="position: relative; text-align: center;">
            <img src="/images/layout/saporo_page2_log.png" width="412"/>
            <a href="#" onclick="facebookLogin();" class="facebook-button"></a>

        </div>
    </div>
</div>
<script type="text/javascript">

    // Handles the response from getting the user's login status.
    // If the user is logged in and the app is authorized go ahead
    // and start running the application. If they are not logged in
    // then redirect to the auth dialog.
    function onCheckLoginStatus (response)
    {
        if (response.status != "connected")
        {
            top.location.href = "https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + encodeURIComponent (redirectUrl) + "&scope=user_photos,friends_photos";
        }
        else
        {
//            alert("da dang nhap");
             window.location.href ="https://www.facebook.com/Sapporo.vn";
        }
    }

    window.fbAsyncInit = function () {
        FB.init({ appId:'132080830287835',
            status:true,
            cookie:true,
            xfbml:true,
            oauth:true});
    };

    function facebookLogin()
    {
        FB.login(function (response) {
            if (response.authResponse) {
                FB.api('/me', function (response) {
                    FB.getLoginStatus (onCheckLoginStatus);
                });
            }
        }, {scope:'email'});
    }

    (function () {
        var e = document.createElement('script');
        e.async = true;
        e.src = document.location.protocol
                + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    }());


</script>

</body>
</html>